<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
    <style>
        body ,
        html{
            margin: 0;
            width: 100%;
            height: 100%;
        }

        ul ,
        li{
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .container {
            width: 100%;
            height: 100%;
        }

        .tab-list {
            height: 39px;
            border: 1px solid #ccc;
            background-color: #f1f1f1;
        }

        .tab-list li {
            float: left;
            height: 39px;
            line-height: 39px;
            padding: 0 20px;
            text-align: center;
            cursor: pointer;
        }

        .tab-list .current {
            background-color: deepskyblue;
            color: #fff;
        }

        .item {
            display: none;
        }
    </style>
</head>
<body>
    <div class="contanier">
        <div class="tab-list">
            <ul>
                <li class="current">基本简介</li>
                <li>经历</li>
                <li>项目</li>
                <li>职业技能</li>
                <li>自我介绍</li>
            </ul>
        </div>

        <div class="content">
            <div class="item" style="display: block;">基本简介</div>
            <div class="item">经历</div>
            <div class="item">项目</div>
            <div class="item">职业技能</div>
            <div class="item">自我介绍</div>
        </div>
    </div>
    <script>
        var lis = document.querySelectorAll(".tab-list ul > li");
        var item = document.querySelectorAll(".content > .item");
        for(var i = 0 ; i < lis.length ; i ++) {
            lis[i].setAttribute("data-index" , i);
            lis[i].onclick = function () {
                for(var j = 0 ; j < lis.length ; j ++) {
                    lis[j].className = "";
                    item[j].style["display"] = "none";
                }
                var index = this.getAttribute("data-index");
                this.className = "current";
                item[index].style["display"] = "block";
            }
        }
    </script>
</body>
</html>